﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using ZLDC.Common.BaseUser;
using ZLDC.Common.Estate;

namespace ZLDC.DAL.Estate
{
    public class MenuDAL
    {
                                                public static DataTable GetT_s_pdmParentMenu(string menuName, _Database db)
        {
            DataTable dt = new DataTable();
            
            string strSql = "select menu,min(OrderNo)as orderno from zldc_t_s_pdm where isMenu=1 and IsActive=1 and mdl= '" + menuName + "' group by menu order by OrderNo ";

            try
            {
                DataSet ds = db.Query(strSql);
                if (ds != null && ds.Tables.Count > 0)
                    dt = ds.Tables[0];
            }
            catch { }
            finally { db.close(); }
                                 
            return dt;
        }

                                                public static DataTable GetT_s_pdmByMdl(string strMdl, _Database db)
        {
            DataTable dt = new DataTable();

            string strSql = "select * from zldc_t_s_pdm where isMenu=1 and IsActive=1 and menu='" + strMdl.Trim() + "' order by OrderNo ";

            try
            {
                DataSet ds = db.Query(strSql);
                if (ds != null && ds.Tables.Count > 0)
                    dt = ds.Tables[0];
            }
            catch { }
            finally { db.close(); }
            
            return dt;
        }
    }
}
